
#include <server_share/msg_struct_login.h>

#include "msg_ls.h"
#include "client_mgr.h"
#include "session_mgr.h"
#include "frontend_service.h"

using namespace NLMISC;
using namespace NLNET;
using namespace FES;
using namespace DEF;
using namespace std;


void cbGetFesInfo ( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
	MSG_STR::CFrontEnd frontEnd;
	frontEnd.SId   = TServiceId(FrontEndService->ConfigFile.getVar ("SId").asInt());
	frontEnd.Ip    = FrontEndService->ConfigFile.getVar ("INetIP").asString();
	frontEnd.Port  = FrontEndService->ConfigFile.getVar ("INetPort").asInt();
	frontEnd.MaxPlayers  = FrontEndService->ConfigFile.getVar ("INetPort").asInt();
	frontEnd.CurrPlayers = ClientMgr.currClients();

	CMessage msgout("SET_FES_INFO");
	msgout.serial(frontEnd);
	NLNET::CUnifiedNetwork::getInstance()->send ("LS", msgout);
}

void cbClientGetSession ( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
	UID    id;
	string name;
	msgin.serial(id);
	msgin.serial(name);

	TTicks session = SessionMgr.pushUser( name, id );

	CMessage msgout("SET_SESSION");
	msgout.serial(name);
	msgout.serial(session);
	NLNET::CUnifiedNetwork::getInstance()->send ("LS", msgout);
}

